<?php
class CateAttr extends BaseAttr {
	public function CateAttr($attr, $lang=null, $mutil_lang=false){
		parent::BaseAttr($attr, $lang, $mutil_lang);
	}
	
	protected function init_data(){
// 		$model = $this->formHelper->model_name;
		$id = $this->attr['id'];
		$model = $this->formHelper->form['items'][$id]['cate'];
// 		if(strpos($model,'_cate')<=-1){
// 			//如果不包含_cate的，则自行添加
// 			$model .= '_cate';
// 		}
		
		$mod = $this->get_cate_mod($model);
		if($this->mutil_lang!==false){
			$cates = $mod->get_cates(SITE_ID, $this->lang . ',parent');
			lang_fatch($cates, $this->lang);
		}else{
			$cates = $mod->get_cates(SITE_ID);
		}
		
		$tree = new Tree($cates);
		$options = $tree->get_options('　', '--请选择--', '0');
// 		print_r($options);
		return array(
			'options' => $options
		);
	}
	
	private function get_cate_mod($name){
		$cate_names = array(
			'goods' => 'goods_cate',
			'article' => 'article_cate',
			'navigate' => 'navigate',
		);
		$mod = m($cate_names[$name]);
		return $mod;
	}
}

?>